/*
|--------------------------------------------------------------------------
| 全局工具包
|--------------------------------------------------------------------------
*/
import SETTINGS from '@/settings';
var moment = require('@/utils/moment.js');
/**
 * 处理图片地址
 * @param {string} url 图片地址
 * @returns 图片地址
 */
export function mmvImageUrl(url) {
	if (uni.$u.test.isEmpty(url)) {
		// return url;
		return 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Ffbf18a5314f750da671711dfb176cf8791fbc687153d-g7YSBF_fw658&refer=http%3A%2F%2Fhbimg.b0.upaiyun.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1648359683&t=f1f85165dfcd41fa2183e748ea2e458d';
	}
	if (uni.$u.test.url(url)) {
		return url;
	}
	if (uni.$u.test.contains(url, 'static/')) {
		return url;
	}
	return SETTINGS.baseImageUrl + url;
}

// 通过日期获取星期
export function week(time) {
	let m1 = moment().format('YYYY-MM-DD');
	let m2 = moment(time).format('YYYY-MM-DD');
	let day = moment(m2).diff(m1, 'day');
	var weekInfo = '';
	let week = moment(time).day();
	switch (week) {
		case 1:
			weekInfo = '周一'
			break
		case 2:
			weekInfo = '周二'
			break
		case 3:
			weekInfo = '周三'
			break
		case 4:
			weekInfo = '周四'
			break
		case 5:
			weekInfo = '周五'
			break
		case 6:
			weekInfo = '周六'
			break
		case 0:
			weekInfo = '周日'
			break
	}
	if(day == 0) {
		weekInfo = weekInfo + ' (今天)'
	}else if(day == 1) {
		weekInfo = weekInfo + ' (明天)'
	}

 return weekInfo;

}
